<?
include_once("/var/www/html/new/com.inc.php");// 公用头部
include_once('/var/www/html/new/d/shops/nav.cfg.php');
//include_once("/var/www/html/new/d/common/yd.le.je");//连接云顶的数据库
//$ydle=new yd_go_sql();
//$ydle->connect();

// 通过二级域名找到该域名绑定账户
$host = str_replace('www.', '', $_SERVER['HTTP_HOST']);
$applyAccount   = substr($host, 0, strpos($host, '.12301'));
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis_key      = "shop_{$applyAccount}";
//$redis->delete($redis_key);
// $redis->setex($redis_key, 1800,'');
$shop           = $redis->get($redis_key);

if (!$shop) {
    $sql = "SELECT `fid`,`M_domain`, `M_name`, `M_logo1`, `M_logo2`, `M_banner`,`M_banner_url`, `M_navi`, `M_qq`, `M_tel`, `M_host`,`M_addr` FROM pft_member_domain_info WHERE M_domain='{$applyAccount}' or M_account_domain='{$applyAccount}' LIMIT 1";
    $GLOBALS['le']->query($sql);
    $shop = $GLOBALS['le']->fetch_assoc();
    if ($shop) {
        $redis->setex($redis_key, 1800, serialize($shop));
    }else{
		// 没配置二级域名如果是账号访问则生成
		if(is_numeric($applyAccount)){
			$sql="select id from pft_member where account='{$applyAccount}' limit 1";
			$GLOBALS['le']->query($sql);
			$GLOBALS['le']->fetch_assoc();
			if(($sid=$GLOBALS['le']->f('id'))){// 存在该账号
				$shop = array(
					'fid'=>$sid,
					'M_account_domain'=>$applyAccount,
					'M_domain'=>$applyAccount,
					'M_logo1'=>'http://www.12301.cc/shops/images/default/index_logo.png',
					'M_logo2'=>'http://www.12301.cc/shops/images/default/index_logo.png',
					'M_banner'=>'http://www.12301.cc/shops/images/default/login_banner_b.jpg',
					'M_tel'=>'400-99-22301',
					'M_addr'=>'联系地址:福建省福州市鼓楼区西二环218号伯爵大酒店6楼',
				);
				$sql="insert into `pft_member_domain_info` set fid=$sid,M_account_domain='$applyAccount',M_domain='$applyAccount',M_logo1='{$shop['M_logo1']}',M_logo2='{$shop['M_logo2']}',M_banner='{$shop['M_banner']}',M_tel='{$shop['M_tel']}',M_addr='{$shop['M_addr']}',createtime=now()";
				$GLOBALS['le']->query($sql);
			}	
		}
	}
}
else {
    $shop = unserialize($shop);
}
if(!isset($_SESSION['domain_mid'])){
    $_SESSION['domain_mid'] = $shop['fid'];
}
define('APPLY_DID', $_SESSION['domain_mid']);

if(!APPLY_DID)exit('非法访问');

$script = substr($_SERVER['SCRIPT_URL'],(strrpos($_SERVER['SCRIPT_URL'],'/')+1));
if(in_array($script,$login) && !$_SESSION['memberID']){// 必须登录，没有登录
    echo '<script>alert("您未登录，请先登录");</script>';
    echo '<script>window.location.href="home.html"</script>';
    exit;
}
$memberID = $_SESSION['memberID'];
$cartCount = 0;// 初始购物车数量
$loginState = 0;// 初始登录标志（未登录）
if($memberID){
    $str = "select count(*) as c from uu_shoppingcart where fid=$memberID and access='{$_SERVER['HTTP_HOST']}'";
    $GLOBALS['le']->query($str);
    $row = $GLOBALS['le']->fetch_assoc();
    $cartCount = $row['c'];
    $cartCount = ($cartCount=="") ? 0:$cartCount;
    $loginState = 1 ; //登录
    // echo $cartCount;
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7 ie6"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8 ie7"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9 ie8"> <![endif]-->
<!--[if IE 9]>         <html class="no-js lt-ie10 ie9"> <![endif]-->
<!--[if gt IE 9]><!--> <html> <!--<![endif]-->
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta charset="UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="description" content=""/>
	<meta name="keywords" content=""/>
	<link rel="stylesheet" href="http://www.12301.cc/shops/css/base.css"/>
	<link rel="stylesheet" href="http://www.12301.cc/shops/css/global.css"/>
	<script language="javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="http://www.12301.cc/shops/js/global.js"></script>
	<title><?=$nav[$script]['title']?></title>
	<style>
	.bgc{background-color: #f9f5f2}
	.main_top{width: 1000px; margin: 0 auto; height: 100%;}
	.header_top{border-bottom: 5px solid #0060b3; height: 138px; overflow: hidden;}
	.logo_top{width:200px; margin: 12px 0 0 10px;}
	.topbar{width: 706px; height: 100%; background-image:url(images/gly_new/images/t_bg.png); overflow: hidden;}
	.topbar .bar{height: 45px; color: #0068b7; overflow: hidden;}
	.topbar .bar li{display: inline-block;float: left;}
	.topbar .welcome{font-size: 14px;margin: 0 25px 0 0px;_margin-left: 30px;line-height: 45px; }
	.topbar .search{background: url(images/gly_new/images/t_search.png) no-repeat 0 center; height: 27px; line-height: 27px; width: 290px; overflow:hidden; margin-top: 8px;}
	.topbar input{border: 0; margin-left:10px; width: 75%; height: 20px;  line-height: 20px;  margin-top: 3px; display: inline-block;}
	.topbar .search a{display: inline-block; height: 100%; width:15%;}
	.topbar .btn{margin: 11px 0 0 3px; width: 94px; height: 23px; line-height: 23px; background:url(images/gly_new/images/ico-1.png) no-repeat center; text-align: center; color: #fff; font-weight: bold; display: inline-block;}
	.topbar .btn a{color: #fff;}
	.topbar .btn a:hover{color:#ef7512; text-decoration:underline;}
	.topbar .btn .h{line-height: 23px; }
	.left_top {float: left;}
	.right_top {float: right;}
		.topbar .btna{margin: 11px 0 0 3px; width: 60px; height: 23px; line-height: 23px; background:url(images/gly_new/images/ico-a.png) no-repeat center; text-align: center; color: #fff; font-weight: bold; display: inline-block;}
	.topbar .btna a{color: #fff;}
	.topbar .btna a:hover{color:#ef7512; text-decoration:underline;}
	.topbar .btna .h{line-height: 23px; }
	.topcart {background:url(images/gly_new/images/cartico.png) no-repeat 0 center; text-indent: 22px; margin: 0 5px; color: #0068b7;}
	.topcart a{color: #0068b7;}
	.topcart  em{font-style: normal; font-weight: bold;color: #e53f04;}

	/* mainMenu */
	.mainMenu{height: 30px; line-height: 30px; margin: 40px 0 0 40px;  font-size: 14px; font-weight: bold;}
	.mainMenu a{color: #959083;}
	.mainMenu li{float: left; display: inline-block;  margin:0 16px;margin-left:12px\9;margin-right:12px\9;+margin-left:12px;+margin-right:12px;_margin:0 11px;margin-left:12px\9\0;margin-right:12px\9\0;}
	.mainMenu .sel a,.mainMenu li a:hover{color: #0060b3;}
	
	</style>
</head>
<input type="hidden" value="<?=$loginState?>" id="iflogin" />
<body>
	<div class="header_top bgc">
                <!-- main -->
                <div class="main_top">
                    <div class="logo_top left_top">
                        <a href="http://112.74.82.250/index.aspx">
                            <img src="images/gly_new/images/logo.jpg" alt="点击返回首页"></a></div>
                    <div class="topbar right_top">
                        <ul class="bar">
                            <li class="welcome">欢迎登录鼓浪屿票务网</li>
                            <li class="search" id="topsearch"></li>
                            <!--<li class="btn"><a href="http://112.74.82.250/login.aspx">登录</a> | <a href="http://112.74.82.250/reg.aspx">注册</a> </li>-->
                            <li class="h"><a href="http://112.74.82.250/help.aspx" class="btn">帮助中心</a></li>
                            <!--<li class="h"><a href="#" class="btna">中文版</a></li>-->
                            <li class="h"><a href="http://112.74.82.250/index_y.aspx" class="btna">English</a></li>
                        </ul>
                        <div class="clear">
                        </div>
                        <ul class="mainMenu">
                            <li><a href="http://112.74.82.250/index.aspx">首 页</a></li>
                            <li class="sel"><a href="http://www.glyvc.com/" target="_blank">票务预订</a></li>
                            <li><a href="./ticke_files/ticke.html" target="_blank">酒店预订</a></li>
                            <li><a href="http://112.74.82.250/hotspots.aspx" target="_blank">热门景点</a></li>
                            <li><a href="http://112.74.82.250/souvenir.aspx" target="_blank">旅游纪念品</a></li>
                            <li><a href="http://112.74.82.250/news.aspx" target="_blank">旅游资讯</a></li>
                            <li><a href="http://112.74.82.250/user.aspx" target="_blank">会员中心</a></li>
                        </ul>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>
<script>
$(function(){
	G.Login.init();
})
</script>
<div id="gLoginPopW" class="gLoginPopW">
<div class="gloginMask"></div>
	<div class="gloginMain">
		<div class="inerMain">
			<div class="loginslideW">
				<div id="loginSlideUl" class="loginSlideUl clearfix">
					<div class="loginW floatBox">
						<div class="glgInpCtrol user">
							<div class="cen"><input type="text" name="" tabIndex="1" id="glogin_userInp" class="gloginInp tabInp usernameInp varifyInp" /></div>
							<span class="lf glgIcon inpTri"></span>
							<span class="rig glgIcon inpTri"></span>
							<span class="glgIcon user icon"></span>
						</div>
						<p class="errorTip">*用户名不存在</p>
						<div class="glgInpCtrol password">
							<div class="cen"><input type="password" name="" tabIndex="2" id="glogin_passwordInp" class="gloginInp tabInp passwordInp varifyInp" /></div>
							<span class="lf glgIcon inpTri"></span>
							<span class="rig glgIcon inpTri"></span>
							<span class="glgIcon password icon"></span>
						</div>
						<p class="errorTip">*密码错误</p>
						
						<div class="botW clearfix">
							<a href="javascript:" id="glogin_loginBtn" class="loginBtn glgIcon fl">登录</a>
							<span class="rig fl">
								<a href="javascript:" class="singup fl">注册</a>
								<span class="lin fl">|</span>
								<a href="../forget.html" class="forget fl">忘记密码?</a>
							</span>
						</div>
					</div>
					<div class="singupW floatBox">
						<div class="glgInpCtrol tel">
							<div class="cen"><input type="text" name="" tabIndex="-1" id="glogin_telInp" class="gloginInp telInp varifyInp" /></div>
							<div class="lf glgIcon inpTri"></div>
							<div class="rig glgIcon inpTri"></div>
							<span class="glgIcon tel icon"></span>
						</div>
						<p class="tip" style="margin-top:3px;"><span style="color:#1b8cd3">初始密码为手机号后六位</span>，如需更改请进个人中心</p>
						<div class="glgInpCtrol yanzheng fl">
							<div class="cen"><input type="text" id="glogin_macodeInp" name="" id="" tabIndex="-1" class="gloginInp" /></div>
							<div class="lf glgIcon inpTri"></div>
							<div class="rig glgIcon inpTri"></div>
						</div>
						<input id="glogin_getmaCode" class="getmaCode fl" type="button" value="获取验证码" />
						<div class="clearfix"></div>
						<div class="botW clearfix">
							<a href="javascript:" id="glogin_singupBtn" class="singupBtn glgIcon fl">注册</a>
							<span class="rig fl">已有帐号？<a href="javascript:" class="sloginBtn">登录</a></span>
						</div>
					</div>
				</div>
			</div>
			<a href="javascript:" class="gloginPopClose glgIcon close"></a>
		</div>
	</div>
</div>